// const express = require("express");
//导入操作server的数据模型
//引入数据库
const mysql = require('mysql');
const config = require('./config')

//实现本地链接
const connection = mysql.createConnection({
    host: config.host,
    user: config.user,
    password: config.password,
    multipleStatements: true,
    database: config.database
})


//数据库连接判断
connection.connect((err) => {
    if (err) throw err;
    console.log("数据库连接成功0")
})


// 第一种数据库操作1
const ldz2FristWrite = (req, res) => {
    // connection.query('INSERT INTO dayyeild SET  ?', {H0809: 21222, H0910: 122 }, function (err, data) {
        const sql = `INSERT INTO  dayyeild SET ?`;
        let writeData = {date:20201013, H1112: 12222, H0910: 32322 };
        connection.query(sql, writeData, (err, result) => {
        if (err) {
            console.log('插入数据失败1',err)
        } else {
            console.log('插入数据成功1',writeData);
            connection.query('SELECT * FROM  dayyeild WHERE id =138 ', function (err, data) {
                if (err) {
                    console.log('查询数据失败1',err);
                } else {
                    console.log("写入成功1，查询结果：", data[0].id)
                }
                connection.end() ;
            })
        }
    })
}
ldz2FristWrite()


// socket打印机连接
const ConnectPrint = require('./ConnectPrint')
